/*    */ package com.hp.bon.sgw.core.channel.handler;
/*    */ 
/*    */ import com.hp.bon.sgw.bean.XmlMessage;
/*    */ import com.hp.bon.sgw.core.CallParam;
/*    */ import com.hp.bon.sgw.threads.TaskManager;
/*    */ import java.io.PrintStream;
/*    */ import org.slf4j.Logger;
/*    */ import org.slf4j.LoggerFactory;
/*    */ 
/*    */ public class NPHandler
/*    */   implements IAsynCallHandler
/*    */ {
/* 15 */   private static final Logger logger = LoggerFactory.getLogger(NPHandler.class);
/*    */   PrintStream printStream;
/*    */ 
/*    */   public NPHandler(PrintStream printStream)
/*    */   {
/* 20 */     this.printStream = printStream;
/*    */   }
/*    */ 
/*    */   public void onCallResult(CallParam callParam)
/*    */   {
/* 25 */     XmlMessage response = (XmlMessage)callParam.getRecvResponse();
/* 26 */     if (response == null) {
/* 27 */       logger.warn("NP message: " + callParam.getSessionId() + " cannot find route");
/*    */       try {
/* 29 */         String msg = "NP message: " + callParam.getSessionId() + " cannot find route";
/* 30 */         this.printStream.write(msg.getBytes("UTF-8"));
/*    */       } catch (Exception e) {
/* 32 */         e.printStackTrace();
/*    */       }
/*    */     }
/*    */     else {
/*    */       try {
/* 37 */         XmlMessage ack = new XmlMessage(false);
/* 38 */         ack.setLength(response.getLength());
/* 39 */         ack.setMsgTime(System.currentTimeMillis());
/* 40 */         callParam.setResponse(ack);
/*    */ 
/* 42 */         byte[] resp = response.getDATA().getBytes("UTF-8");
/* 43 */         this.printStream.write(resp);
/* 44 */         if (logger.isInfoEnabled())
/* 45 */           logger.info("NP response  " + response.getDATA());
/*    */       }
/*    */       catch (Exception e) {
/* 48 */         e.printStackTrace();
/*    */       }
/*    */     }
/* 51 */     this.printStream.close();
/* 52 */     TaskManager.taskProcess(callParam);
/*    */   }
/*    */ 
/*    */   public int getProtocolType()
/*    */   {
/* 58 */     return 3;
/*    */   }
/*    */ }

/* Location:           C:\Users\think\Desktop\sgw_2.1.jar
 * Qualified Name:     com.hp.bon.sgw.core.channel.handler.NPHandler
 * JD-Core Version:    0.6.1
 */